import request from './axios'
import {DEFAULT_PAGENUM, DEFAULT_PAGESIZE} from "@/constent";

/**
 * 获取菜单列表
 * @returns {AxiosPromise}
 */
export const getMenuList = (pageNum = DEFAULT_PAGENUM,pageSize = DEFAULT_PAGESIZE) => {
    return request({
        url:'/menu/getMenuList',
        method:'get',
        params:{
            pageNum,
            pageSize
        }
    })
}

/**
 * 获得所有父菜单
 * @returns {AxiosPromise}
 */
export const getParentMenuIdList = () => {
    return request({
        url:'/menu/getMenuParentIdList',
        method:'get'
    })
}

/**
 * 修改菜单
 * @param data
 * @returns {Promise<AxiosResponse<any>>}
 */
export const updateMenu = (data = {}) => {
    return request.post('/menu/updateMenu',data);
}

/**
 * 删除菜单
 * @param id
 * @returns {AxiosPromise}
 */
export const removeMenu = (id) => {
    return request({
        url:'/menu/removeMenu',
        method:'get',
        params:{
            id
        }
    })
}

/**
 * 获得菜单的树形结构
 * @returns {AxiosPromise}
 */
export const getMenuTreeList = () => {
    return request({
        url:'/menu/getMenuTreeList',
        method:'get'
    })
}
